/**
 * @(#)com.framework.web.sys.service.RoleService
 *
 * Copyright (c) 2014-2018 上海天跃科技有限公司
 *
 * DESC:
 *
 */
package com.framework.web.sys.service;

import com.framework.core.constant.Globals;
import com.framework.core.util.MyBeanUtils;
import com.framework.web.sys.domain.Role;
import com.framework.web.sys.domain.UserRole;
import com.framework.web.sys.repository.RoleRepository;
import com.framework.web.sys.repository.UserRoleRepository;
import com.framework.web.sys.repository.specifications.RoleSpecs;
import com.framework.web.sys.vo.RoleVo;
import com.mchange.v2.codegen.bean.BeangenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fusf
 * @version 1.0  2016/1/8
 */
@Service
public class RoleService {

    @Autowired
    private RoleRepository roleRepository;

    /**
     * 新增或者保存
     * @param role
     * @return
     */
    public Role save(Role role) {
        return roleRepository.save(role);
    }

    /**
     * 删除
     * @param id
     */
    public void  delete(String id) {
        roleRepository.delete(id);
    }
    /**
     * 根据id查询
     * @param id
     * @return
     */
    public Role findById(String id) {
        return roleRepository.findOne(id);
    }


    /**
     * 分页查找
     * @param role
     * @param pr
     * @return
     */
    public Page<Role> getPageList(Role role, PageRequest pr) {
        Page<Role> totalList = roleRepository.findAll(
                RoleSpecs.LikeRoleName(role), pr);
        return totalList;
    }



}
